package com.czx.controller;

import com.czx.strategy.StrategyContext;
import com.czx.strategy.payment.PaymentStrategy;
import com.czx.strategy.sms.SmsStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @Autowired
    private StrategyContext strategyContext;

    @GetMapping("testPay")
    public void testPay(String strategyId) {
        PaymentStrategy strategy = strategyContext.getStrategy(strategyId, PaymentStrategy.STRATEGYTYPE, PaymentStrategy.class);
        strategy.pay();
    }

    @GetMapping("testSms")
    public void testSms(String strategyId) {
        SmsStrategy strategy = strategyContext.getStrategy(strategyId, SmsStrategy.STRATEGYTYPE, SmsStrategy.class);
        strategy.send();
    }
}
